#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <iostream>
#include <string>
using namespace std;
#include <cctype>

class Solution
{
public:
	bool isPalindrome(string s)
	{
		int len = s.size();
		int left = 0;
		int right = len - 1;
		while (left < right)
		{
 			while (left < right && isalnum(s[left]) == 0)
			{
				++left;
			}
			while (left < right && isalnum(s[right]) == 0)
			{
				--right;
			}
			if (tolower(s[left]) != tolower(s[right]))
			{
				return false;
			}
			++left;
			--right;
		}

		return true;
	}
};

int main()
{
	string s1("A man, a plan, a canal: Panama");
	Solution solution;
	if (solution.isPalindrome(s1))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	//int left = 0;
	//int right = s1.size() - 1;
	//tolower(s1[left]) != tolower(s1[right]);

	return 0;
}